<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simpla Admin</title>
<jsp:include page="css.jsp"></jsp:include>
<jsp:include page="script.jsp"></jsp:include>
<script type="text/javascript">

	var path = '<%=request.getContextPath()%>';
	function goPage(page) {
		document.getElementById("currentPage").value = page;
		document.getElementById("n_form").submit();
	}

	function promptDialog(callback, args) {
		$("<div>해당조작을 하시겠습니까?</div>").dialog({
			title:'확인?',
			modal:true,
			resizable:false,
			draggable:false,
			close : function (event) {
				$(this).dialog("destroy");
			}, 
			buttons : {
				'확인':function (event) {
					$(this).dialog("destroy");
					if (args != null) {
						callback(args);
					} else {
						callback();
					}
				},
				'취소':function (event) {
					$(this).dialog("destroy");
				}
			}
		});
	}
	
	function openVip(_id){
		$.ajax({
			type : "GET",
			url : path + "/openVip.htm",
			data : {
				uid : _id
			},
			dataType : "text",
			success : function(result) {
				if (result == "success") {
					//showAlertDialog("操作成功！",reload);
					reload();
				} else {
					showAlertDialog("삭제에 실패하였습니다!",null);
				}
			},
			error : function() {
				showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
			}
		});
	}
	
	
	function closeVip(_id){
		$.ajax({
			type : "GET",
			url : path + "/closeVip.htm",
			data : {
				uid : _id
			},
			dataType : "text",
			success : function(result) {
				if (result == "success") {
					//showAlertDialog("操作成功！",reload);
					reload();
				} else {
					showAlertDialog("삭제에 실패하였습니다!",null);
				}
			},
			error : function() {
				showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
			}
		});
	}

	function rebind(_id){
		$.ajax({
			type : "GET",
			url : path + "/rebind.htm",
			data : {
				uid : _id
			},
			dataType : "text",
			success : function(result) {
				if (result == "success") {
					//showAlertDialog("操作成功！",reload);
					reload();
				} else {
					showAlertDialog("삭제에 실패하였습니다!",null);
				}
			},
			error : function() {
				showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
			}
		});
	}
	
	function deleteUser(_id){
		$.ajax({
			type : "GET",
			url : path + "/deleteUser.htm",
			data : {
				uid : _id
			},
			dataType : "text",
			success : function(result) {
				if (result == "success") {
					//showAlertDialog("操作成功！",reload);
					reload();
				} else {
					showAlertDialog("삭제에 실패하였습니다!",null);
				}
			},
			error : function() {
				showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
			}
		});
	}
	
	function reload() {
		document.getElementById("n_form").submit();
	}
</script>
</head>
<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->
		<div id="sidebar">
			<div id="sidebar-wrapper">
				<!-- Sidebar with logo and menu -->
				<h1 id="sidebar-title">
					<a href="#">Simpla Admin</a>
				</h1>
				<!-- Logo (221px wide) -->
				<a href="#"><img id="logo" src="<%=request.getContextPath()%>/images/logo.png" alt="Simpla Admin logo" /></a>
				<!-- Sidebar Profile links -->
				<jsp:include page="info.jsp"></jsp:include>
				<ul id="main-nav">
					<!-- Accordion Menu -->
					<li><a href="javascript:void();" class="nav-top-item current"> <!-- Add the class "current" to current menu item --> 회원관리
					</a>
						<ul>
							<li><a href="<%=request.getContextPath()%>/userList.htm" <s:if test="type==0"> class="current" </s:if>>모든회원</a></li>
							<li><a href="<%=request.getContextPath()%>/userList.htm?type=1" <s:if test="type>0"> class="current" </s:if>>정회원</a></li>
							<!-- Add class "current" to sub menu items also -->
							<li><a href="<%=request.getContextPath()%>/userList.htm?type=-1" <s:if test="type<0"> class="current" </s:if>>비정회원</a></li>
						</ul></li>
					<li><a href="javascript:void();" class="nav-top-item">개인정보변경</a>
						<ul>
							<li><a href="<%=request.getContextPath()%>/changePwd.htm">비밀번호 변경</a></li>
							<li><a href="javascript:logout('<%=request.getContextPath()%>');">로그아웃</a></li>
						</ul></li>
				</ul>
			</div>
		</div>
		<!-- End #sidebar -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<jsp:include page="noscript.jsp"></jsp:include>
			<!-- End .shortcut-buttons-set -->
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box -->
				<div class="content-box-header">
					<h3>회원관리</h3>
					<div class="clear"></div>
				</div>
				<!-- End .content-box-header -->
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<table>
							<thead>
								<tr>
									<th style="display: none;"><input class="check-all" type="checkbox" /></th>
									<th>아이디(휴대폰번호)</th>
									<th>비밀번호</th>
									<th>초기설치기기일련번호</th>
									<th>사용중인기기일련번호</th>
									<th>개통시간</th>
									<th>정회원</th>
									<th>다시묶기</th>
									<th>삭제</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td colspan="6">
										<form action="<%=request.getContextPath()%>/userList.htm" method="post" id="n_form">
											<div class="pagination">
												<s:if test="users.currentPage<2">
													<a href="javascript:void();" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:void();" title="이전페지">&laquo; 이전페지</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(1);" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:goPage(${users.currentPage}-1);" title="이전페지">&laquo; 이전페지</a>
												</s:else>
												[제<b>${users.currentPage}</b>페지|총<b>${users.pageCount}</b>페지]
												<s:if test="users.currentPage>=users.pageCount">
													<a href="javascript:void();" title="다음페지">다음페지 &raquo;</a>
													<a href="javascript:void();" title="마지막페지">마지막페지 &raquo;</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(${users.currentPage+1});" title="다음페지">다음페지 &raquo;</a>
													<a href="javascript:goPage(${users.pageCount})" title="마지막페지">마지막페지 &raquo;</a>
												</s:else>
											</div>
											<!-- End .pagination -->
											<div class="clear"></div>
											<input type="hidden" name="type" value="${type}" /> <input type="hidden" value="${users.currentPage}" name="cPage"
												id="currentPage" />
										</form>
									</td>
								</tr>
							</tfoot>
							<tbody>
								<s:iterator value="users.datas" id="item" status="index">
									<tr>
										<td style="display: none;"><input type="checkbox" /></td>
										<td><a href="<%=request.getContextPath()%>/contactList.htm?uid=<s:property value="#item.id"/>" target="_blank"><s:property value="#item.phone"/></a></td>
										<td><s:property value="#item.password"/></td>
										<td><s:property value="#item.bindImei"/></td>
										<td><s:property value="#item.newImei"/></td>
										<td>
											<s:if test="#item.vip">
												<s:date name="#item.openVipDate" nice="false" format="yyyy-MM-dd HH:mm" />
											</s:if>
										</td>
										<td><s:if test="#item.vip">
												<input class="button" type="button" value="취소" onclick="promptDialog(closeVip,'<s:property value="#item.id"/>');" />
											</s:if> <s:else>
												<input class="button" type="button" value="개통" onclick="promptDialog(openVip,'<s:property value="#item.id"/>');" />
											</s:else></td>
										<td><s:if test="#item.vip">
												<input class="button" type="button" value="다시묶기" onclick="promptDialog(rebind,'<s:property value="#item.id"/>');" />
											</s:if> <s:else>
												<input class="disable_button" type="button" value="다시묶기" />
											</s:else></td>
										<td>
											<img alt="delete" src="<%=request.getContextPath()%>/images/cross.png" style="cursor: pointer;" onclick="promptDialog(deleteUser,'<s:property value="#item.id"/>');">
										</td>	
									</tr>
								</s:iterator>
							</tbody>
						</table>
					</div>
					<!-- End #tab1 -->
				</div>
				<!-- End .content-box-content -->
			</div>
			<!-- End .content-box -->
			<div class="clear"></div>
			<jsp:include page="footer.jsp"></jsp:include>
			<!-- End #footer -->
		</div>
		<!-- End #main-content -->
	</div>
</body>
<!-- Download From www.exet.tk-->
</html>
